package com.shushan.home.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: TotalPlayBean
 * @Desciption: //总玩耍时间数据bean
 * @author: zhangshihao
 * @date: 2018-09-26
 */
public class TotalPlayBean extends NetBaseBean {

    public int time;//分
    private List<TotalPlayListBean> totalPlayListBeans = new ArrayList<>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }

        time = jsonObject.optInt("time",0);
        JSONArray listArr = jsonObject.optJSONArray("list");
        if(listArr != null && listArr.length() > 0){
            for(int i=0;i<listArr.length();i++){
                JSONObject obj = listArr.optJSONObject(i);
                TotalPlayListBean listBean = new TotalPlayListBean();
                listBean.initByJson(obj);
                totalPlayListBeans.add(listBean);
            }
        }

    }

    public class TotalPlayListBean extends NetBaseBean{

        public String app_name;
        public double num;//APP使用时长（秒）

        @Override
        public void initByJson(JSONObject jsonObject) throws JSONException {
            if(jsonObject == null){
                return;
            }

            app_name = jsonObject.optString("app_name","");
            num = jsonObject.optDouble("num",0);
        }
    }

    public List<TotalPlayListBean> getTotalPlayListBeans() {
        return totalPlayListBeans;
    }
}
